#!/usr/bin/env python
#-*-coding:utf-8-*-

import os
import sys




if __name__ == "__main__":
    timestamp = sys.argv[1]
    path = "/data/wellpilot/sync_data/" + timestamp +"/image"
    fl_imnames = os.listdir(os.path.join(path, "front_left"))
    fm_imnames = os.listdir(os.path.join(path, "front_mid"))
    fr_imnames = os.listdir(os.path.join(path, "front_right"))
    tl_imnames = os.listdir(os.path.join(path, "rear_left"))
    tr_imnames = os.listdir(os.path.join(path, "rear_right"))
    rl_imnames = os.listdir(os.path.join(path, "top_left"))
    rr_imnames = os.listdir(os.path.join(path, "top_right"))

    fl_imnames = set([imname.split('_')[0] for imname in fl_imnames])
    fm_imnames = set([imname.split('_')[0] for imname in fm_imnames])
    fr_imnames = set([imname.split('_')[0] for imname in fr_imnames])
    tl_imnames = set([imname.split('_')[0] for imname in tl_imnames])
    tr_imnames = set([imname.split('_')[0] for imname in tr_imnames])
    rl_imnames = set([imname.split('_')[0] for imname in rl_imnames])
    rr_imnames = set([imname.split('_')[0] for imname in rr_imnames])


    intsc = fl_imnames.intersection(fr_imnames, fm_imnames, tl_imnames, tr_imnames, rl_imnames, rr_imnames)
    uni = fl_imnames.union(fr_imnames, fm_imnames, tl_imnames, tr_imnames, rl_imnames, rr_imnames)
    percent = float(len(intsc))/len(uni)
    print("%f valid image." % percent)
